//
//  ProductDetailViewController.m
//  SP2P
//
//  Created by Eternal on 2017/8/22.
//  Copyright © 2017年 EIMS. All rights reserved.
//

#import "ProductDetailViewController.h"
#import "TransferredViewController.h"
@interface ProductDetailViewController ()
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet UILabel *titleLab;
@property (weak, nonatomic) IBOutlet UILabel *subtitleLab;
@property (weak, nonatomic) IBOutlet UILabel *earningValueLab;
@property (weak, nonatomic) IBOutlet UILabel *earningLab;

@property (weak, nonatomic) IBOutlet UILabel *projectLimitLab;

@property (weak, nonatomic) IBOutlet UILabel *projectLimitValueLab;
@property (weak, nonatomic) IBOutlet UILabel *projectSizeLab;
@property (weak, nonatomic) IBOutlet UILabel *projectSizeValueLab;
@property (weak, nonatomic) IBOutlet UIButton *Obutton;
@property (weak, nonatomic) IBOutlet UIButton *Tbutton;
@property (weak, nonatomic) IBOutlet UIButton *Hbutton;
@property (strong, nonatomic)  UILabel *mainTitleLab;
@property (strong, nonatomic)  UILabel *contentLab;
@property (strong, nonatomic)  UILabel *TmainTitleLab;
@property (strong, nonatomic)  UILabel *TcontentLab;
@property (strong, nonatomic)  UILabel *HmainTitleLab;
@property (strong, nonatomic)  UILabel *HcontentLab;
@property (strong, nonatomic)  ClickButton *IntoBtn;
@property (strong, nonatomic)  UIView *bottomView;

@property (strong, nonatomic)  UILabel *textLabel;
@end

@implementation ProductDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initNavBarTitle:@"项目详情" andLeftItemName:@"返回" andRightItemName:@""];
    
    [self initView];
}
#pragma mark - initView
- (void)initView{
    self.titleLab.font = KFontSize(13);
    self.subtitleLab.font = KFontSize(10);
    self.earningLab.font = KFontSize(11);
    self.earningValueLab.font = KFontSize(20);
    self.projectLimitLab.font = KFontSize(11);
    self.projectLimitValueLab.font = KFontSize(11);
    self.projectSizeLab.font = KFontSize(11);
    self.projectSizeValueLab.font = KFontSize(11);
    self.Obutton.titleLabel.font = KFontSize(11);
    self.Tbutton.titleLabel.font = KFontSize(11);
    self.Hbutton.titleLabel.font = KFontSize(11);
    self.IntoBtn.titleLabel.font = KFontSize(12);
    self.IntoBtn.layer.cornerRadius = 5;
    self.IntoBtn.layer.masksToBounds = YES;
    
    self.projectLimitValueLab.attributedText = [MyTools getNSMutableAttributedStringWithText:@"12个月" start:0 end:2 textColor:KColor textFont:KFontSize(20)];
    self.projectLimitValueLab.textAlignment = NSTextAlignmentCenter;
    self.projectSizeValueLab.attributedText = [MyTools getNSMutableAttributedStringWithText:@"5000万" start:0 end:4 textColor:KColor textFont:KFontSize(20)];
   
    self.projectSizeValueLab.textAlignment = NSTextAlignmentRight;
    NSString *planStr = [NSString stringWithFormat:@"%@",@"随取宝是随取宝平台依据严格风控标准，挑选品种多样的优质资产为用户提供的投资产品，于固定时间发售，成功借出24小时后可以随存随取，用户投资本息有保障。"];

    NSString *pdStr = [NSString stringWithFormat:@"%@",@"本期随取宝20170801-1的借款方是一家多元化综合型体育旅游企业，原属于上海外经贸投资（集团）有限公司旗下企业，其营业范围主要为销售旅游用品（除专项），房地产开发，收费停车场，自有房屋租赁，物业管理等。注册资本10945万。本项目主要还款来源为借款企业主营业务收入，2016年企业主营业务收入达13亿元。此外借款企业提供充足抵押物进行担保，其信誉良好，能够进一步控制项目风险。本项目融资总金额为13500万元，本期为第一期，融资金额以当天实际借入金额为准。（详见随取宝官网有关介绍）"];
    
    NSString *bcStr = [NSString stringWithFormat:@"%@",@"1.借款企业提供充足的抵押保障，提供一处临近上海内环面积约30000㎡的地产为本项目进行担保;\n2.借款企业以企业所有动产不动产提供保障"];
    
    CGFloat planHeight = [MyTools getSizeOfString:planStr maxWidth:MSWIDTH - KAdaptNum(40) maxHeight:1000 withFontSize:10].height;
    
    CGFloat pdHeight = [MyTools getSizeOfString:pdStr maxWidth:MSWIDTH - KAdaptNum(40) maxHeight:1000 withFontSize:10].height;
    CGFloat bcHeight = [MyTools getSizeOfString:bcStr maxWidth:MSWIDTH - KAdaptNum(60) maxHeight:1000 withFontSize:10].height;
    
     _mainTitleLab = [UILabel labelWithFrame:CGRectMake(KAdaptNum(20), KAdaptNum(200), MSWIDTH-KAdaptNum(40), KAdaptNum(20)) text:@"计划介绍:" textColor:KBlackColor textFont:13 fitWidth:NO superview:_scrollView];
    _contentLab = [UILabel labelWithFrame:CGRectMake(KAdaptNum(20), GetMaxY(_mainTitleLab)+KAdaptNum(5), MSWIDTH-KAdaptNum(40), planHeight) text:planStr textColor:[UIColor darkGrayColor] textFont:10 fitWidth:NO superview:_scrollView];
   _contentLab.numberOfLines = 0;
    
    
    _TmainTitleLab = [UILabel labelWithFrame:CGRectMake(KAdaptNum(20), GetMaxY(_contentLab)+KAdaptNum(10), MSWIDTH-KAdaptNum(40), KAdaptNum(20)) text:@"项目描述:" textColor:KBlackColor textFont:13 fitWidth:NO superview:_scrollView];
    
    _TcontentLab = [UILabel labelWithFrame:CGRectMake(KAdaptNum(20), GetMaxY(_TmainTitleLab)+KAdaptNum(5), MSWIDTH-KAdaptNum(40), pdHeight) text:pdStr textColor:[UIColor darkGrayColor] textFont:10 fitWidth:NO superview:_scrollView];
    _TcontentLab.numberOfLines = 0;
    
    _HmainTitleLab = [UILabel labelWithFrame:CGRectMake(KAdaptNum(20), GetMaxY(_TcontentLab)+KAdaptNum(10), MSWIDTH-KAdaptNum(40), KAdaptNum(20)) text:@"保障措施:" textColor:KBlackColor textFont:13 fitWidth:NO superview:_scrollView];
   
    _HcontentLab = [UILabel labelWithFrame:CGRectMake(KAdaptNum(20), GetMaxY(_HmainTitleLab)+KAdaptNum(5), MSWIDTH-KAdaptNum(40), bcHeight) text:bcStr textColor:[UIColor darkGrayColor] textFont:10 fitWidth:NO superview:_scrollView];
    _HcontentLab.numberOfLines = 0;
    
    NSString *mindStr = [NSString stringWithFormat:@"%@",@"计息方式:投资当日起息,按日计息\n还款方式:按日付息,无转让则到期还本\n债权转让:持有24小时后随时可进行债权转让,随存随取,保证资金流动性\n相关费用:无认购费、管理费,债权转让费率0%"];
    
    CGFloat mindHeight = [MyTools getSizeOfString:mindStr maxWidth:MSWIDTH - KAdaptNum(40) maxHeight:1000 withFontSize:11].height;;
   
    _textLabel = [UILabel labelWithFrame:CGRectMake(KAdaptNum(20), GetMaxY(_HcontentLab)+KAdaptNum(10), MSWIDTH-KAdaptNum(40), mindHeight) text:mindStr textColor:[UIColor darkGrayColor] textFont:11 fitWidth:NO superview:_scrollView];
    _textLabel.numberOfLines = 0;
    self.scrollView.contentSize = CGSizeMake(0, GetMaxY(_textLabel)+110);
}

#pragma mark - Action
- (IBAction)clickInto:(id)sender {
    if (AppDelegateInstance.userInfo == nil) {
        [ReLogin goLogin:self];
        return;
    }
    [self.navigationController pushViewController:[[TransferredViewController alloc] init] animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
